// pages/articles/rank/rank.js

const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    navs: [
      {
        title: '浏览量',
      },
      {
        title: '参与人数',
      }
    ],
    curIndex:0,
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 1000,
    circular: true,
    list:[],
    scrollHeight:0,
    audioIndex:0
  },
  
  getList: function () {
    var pageSize = 10;
    var list = [];
    var curListLen = this.data.list.length;
    for(var i = 0; i < pageSize; i ++) {
      var item = {
        bid: curListLen + i,
        cover:'http://wxbucket.oss-cn-hangzhou.aliyuncs.com/microApp/sxl-mwpd/book.jpg',
        imgUrl:'http://wxbucket.oss-cn-hangzhou.aliyuncs.com/microApp/sxl-mwpd/book.jpg',
        title:'情商（全六册）_' + (curListLen + i),
        haveRed: 1221,
        date: "12-12",
        url:'http://media.jinlanzuan.com/index.php?user/public_link&fid=9d351JCxXmQTFr1GpMbkfCaucCtGOVQRuURrcmIzggj2x8JSBaVSoZX6HMnctfTfxZ74-Vq6rb2WzZXqewVgVkqVYaoJ-QulFSr3-4iw9HLRumMDBigX3LGBbpxK6BEJtYjeTQkUETcw40hDW_xZK8IItNNV8X3fFknCPzkU03sYRHRB1rIRSAZb8dCpB04&file_name=00%B6%D4%B4%FD%C4%E6%BE%B3%B5%C4%CC%AC%B6%C8%A3%AC%BE%F6%B6%A8%C4%E3%C8%E7%BA%CE%B9%FD%D5%E2%D2%BB%C9%FA.mp3',
        audio:''
      };
      list.push(item);
    };
    var curList = this.data.list.concat(list);
    this.setData({
      list: curList
    });
  },

  lower: function () {
    this.getList();
  },

  play: function (event) {
    var index = event.target.dataset.index;

    var player = this.selectComponent('#player');
    console.log(index)
    console.log(player)
    player.play(index);
  },

  changeView:function(event){
    console.log(event)
    var index = event.currentTarget.id;
    if(index == "0"){
      this.setData({
        curIndex: 0
      });
    }else if(index == "1"){
      this.setData({
        curIndex: 1
      });
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      scrollHeight: app.globalData.winHeight - 93
    });
    this.getList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})